home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / sources.arc / LOADSND2.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-03  |  2.8 KB  |  92 lines

  1. #include <globals2.h>
  2.  
  3. /* Loads up PLAY.PRG as TSR. and will call it with arguments.
  4.  
  5.    Now you can include sounds in the form of *.SND files in your code!
  6.  
  7.    Say you are writing a utility program and want to spice it up a bit.
  8.    If the user entered a wrong command, you could play a .SND file 
  9.    that says 'WHAT THE HELL ARE YOU DOING?' 
  10.   
  11.    It adds a nice touch.
  12.  
  13.    
  14.  
  15.  
  16.   ** NOTE ** the format of the command line argument is 
  17.              FILENAME.EXT xxxx
  18.  
  19.              where filename is the FILE.SND 
  20.              and   xxxx     is the Freq. you want to play it as.
  21.  
  22.              ex:   HITHERE.SND 6500 
  23.  
  24.                    will play the file "hithere" at 6500Hz
  25.  
  26.     Thats all there is to it! Enjoy. Jeff Bilger TAMU 3/28/93 3:40am                        
  27. */
  28.  
  29.  
  30.  
  31.   
  32. load_player_as_tsr()
  33. {
  34.   char   work[128];                      /* For conv. C to Pascal like string */
  35.  
  36.      
  37.      addr = Pexec(3,"player",work,"");    /* load it as TSR */
  38.                                           /* addr holds addr of its basepage*/
  39.    
  40.  /*  invoke_tsr(a);     */          /* play a SND file */
  41.  
  42. }
  43.  
  44.  
  45.  
  46. /********************************************************/
  47. /* The COMMAND argument of Pexec requires that the string be in
  48.    the Pascal-like format. ie 1st element in string holds the 
  49.    length of the string.
  50. */
  51.  
  52. convert_string(dest , source )
  53. char dest[];
  54. char source[];
  55.  
  56. {
  57.  
  58.    dest[0] = strlen(source);          /* place length of string in 1st cell of array */
  59.    strcpy(&dest[1],source);           /* copy rest of string */
  60. }
  61.   
  62. /*********************************************/
  63. /* this code will place a *.SND file in the Command
  64.    line arg and play it
  65.  
  66.  */
  67.  
  68. invoke_tsr(a)
  69. char a[];
  70. {
  71.  long cline;                            /* temp addr. Used to store new *.SND file in command line*/
  72.  char   work[20];                      /* For conv. C to Pascal like string */
  73.  
  74. if(sound)         /* if sounds are enabled */
  75. {
  76.   convert_string( work, a);          /* convert to Pascal like string */
  77.       cline = addr;                  /* get addr of basepage */
  78.       cline += 128;                  /* add 128 byte offset,so now
  79.                                         cline points to Command_line*/
  80.       strcpy(cline,work);            /*copy new ttp info to command
  81.                                        line. ie place string *.SND there */
  82.     
  83.   
  84.    Pexec(4,"",(char *)addr,"");  /* invoke the TSR prg. We need to tell it */
  85.                                  /* which one to invoke. We send the basepage addr*/
  86.                                  /* of the prg we want to invoke. We send it*/
  87.                                  /* to the command line string */     
  88.                                  /* we must typecast it */
  89.  } 
  90. }
  91.  
  92.